<?php
use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;

$this->title = Yii::t('app', 'Suppliers');
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="supplier-index">
    <h2 class="page-header"><?= Html::encode($this->title) ?>
        <p class="pull-right"><?= Html::a(Yii::t('app', 'Create Supplier'), ['create'], ['class' => 'btn btn-success']) ?> </p>
    </h2>

	<?PHP Pjax::begin(['id'=>'supplier', 'timeout'=>3000, 'linkSelector'=>'#supplier a[data-sort], #supplier a[data-page]']);?>
        <p><?php  echo $this->render('_search', ['model' => $searchModel]); ?></p>
        <?= GridView::widget([
            'dataProvider' => $dataProvider,
            //'filterModel' => $searchModel,
            'layout'  =>  "{items}\n{pager}",
            'columns' => [
                //['class' => 'yii\grid\SerialColumn'],
                'company',
                'phone',
                'name',
                'mail:email',
                // 'address',
                // 'desc',
                [
                    'attribute' => 'status',
                    'filter' =>  array_merge([3=>'请选择'], Yii::$app->params['status']),
                    'value' => function ($model) {
                        $status = Yii::$app->params['status'];
                        return $status[$model->status];
                        },
                    'format' => 'raw',
                ],
                'created_at:date',
                // 'updated_at',

                ['class' => 'yii\grid\ActionColumn',
                 'header' => '操 作',
                 'template'=>"{view} {update}"
                ], 
                [
                    'label'=>'LOGO(AI)',
                    'format'=>'raw',
                    'value' => function($model){
                        $url = sprintf("%ssupplier_%d.ai",Yii::$app->params['qiniu_path'], $model->id);
                        $str = Html::a('<i class="fa fa-photo"></i>',$url,['title' => '矢量图', 'target'=>'_blank']);
                        return $str;
                    }
                ],
            ],
        ]); ?>
    <?php Pjax::end() ?>
</div>
